• 1、编写vue组件myUploader.js

<template>
    <label :for="dataId" :style="dataStyle" class="upLoaderFile" :class="dataClass">
        <input type="file" class="dishidden fileSelectUpButton" name="file" :id="dataId">
        <slot name="textWord" class="textWord"></slot>
    </label>
</template>
<script>
var fileUpLoader = require('../../libs/uploadFile/js/jquery.fileupload.js'); //上传图片
export default {
    name: "myUpLoad",
}
  • 2、编写vue组件myUploader,在index.js中导入进来(test.js)

import myUploader from "./myUploader ";
var install = function(Vue, options) {
    if (install.installed) return;
    debugger
    Vue.component(myUploader.name, myUploader );
}
export default install;//返回install对象
//module.exports = {install};或者这种方式导入
  • 3、在main.js中引入(main.js)

import myUploader from "./test.js";
Vue.use(myUploader );
  • 4、页面上引入

不用导入,可以直接在想用的地方使用

<my-upLoad></my-upLoad>

西安小哥
1.3k 声望88 粉丝

thinking、doing、do better、do much better than today。exchange 、sharing、improve as quickly as possible。